import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_wan_android/res/colors.dart';
import 'package:flutter_wan_android/res/theme.dart';

WanAppbar(BuildContext context, {
  String? titleStr,
  Widget? title,
  List<Widget>? actions,
  Color? backgroundColor,
  IconThemeData? iconTheme,
}) {
  var _title;
  if (titleStr?.isNotEmpty == true) {
    _title = Text(
      titleStr ?? "",
      style: TextStyle(fontSize: 18),
    );
  } else {
    _title = title;
  }

  // actions?.add(Padding(padding: EdgeInsets.only(right: 16)));

  return AppBar(
    toolbarHeight: 40,
    elevation: 0,
    title: _title,
    backgroundColor: backgroundColor ?? context.wTheme.primary,
    centerTitle: true,
    // titleSpacing: 15,
    actions: actions,
    iconTheme: iconTheme,
  );
}
